@use 'sass:map';
@use 'sass:color';
@use '@angular/material' as mat;

@mixin color($config-or-theme) {
  $config: mat.get-color-config($config-or-theme);
  $background: map.get($config, background);
  $foreground: map.get($config, foreground);
  $primary: map.get($config, primary);
  $accent: map.get($config, accent);

  .ngm-flex-layout {
    position: relative;
    min-width: 50px;
    min-height: 50px;
    --header-size: 10px;

    .ngm-responsive__fab-menu {
      position: absolute;
      top: 0;
      right: -40px;
      z-index: 2;
      visibility: hidden;

      &.rightSide {
        right: 0; // -50px;
      }
    }

    .ngm-responsive__item.widget {
      overflow: visible;
      max-width: 100%;
    }

    &.editable {
      padding-top: var(--header-size);
      border: 2px solid mat.get-color-from-palette($primary, 200);
      transition: all .1s ease-in;
      border-radius: 5px;

      .ngm-responsive__fab-menu {
        visibility: visible;
      }

      .ngm-responsive__item.widget {
        border: 1px solid mat.get-color-from-palette($foreground, divider);
        &.active {
          border: 1px dashed mat.get-color-from-palette($accent);
        }
      }

      .ngm-responsive__header {
        position: absolute;
        top: 0;
        left: 0;
        height: var(--header-size);
        width: 100%;
        text-align: center;
        border-top-left-radius: 3px;
        border-top-right-radius: 3px;
        background-color: mat.get-color-from-palette($primary, 100);
        color: mat.get-color-from-palette($primary, '100-contrast');

        &::before {
          content: '••••';
          font-weight: normal;
          -webkit-font-smoothing: antialiased;
          font-size: 12px;
          line-height: 12px;
          position: absolute;
          margin-left: -13px;
        }
      }

      &.active {
        background: mat.get-color-from-palette($accent, 100);
        border: 2px dashed mat.get-color-from-palette($accent);

        .ngm-responsive__header {
          background-color: mat.get-color-from-palette($accent, 100);
          color: mat.get-color-from-palette($accent, '100-contrast');
        }
      }
    }

    .ngm-story-widget {
      .ngm-story-widget__fab-menu {
        position: absolute;
        top: 0;
        right: 0;
        opacity: .2;
        &:hover {
          opacity: 1;
        }
      }
    }
    
  }
  
}

@mixin density($config-or-theme) {
}

@mixin theme($theme) {

  $density: mat.get-density-config($theme);

  $color-config: mat.get-color-config($theme);
  @if $color-config != null {
    @include color($theme);
  }

  $typography-config: mat.get-typography-config($theme);
  @if $typography-config != null {
    @include typography($theme);
  }
  
  @if $density != null {
    @include density($density);
  }
}